package com.lzh.user.controller;


import com.lzh.common.pojo.Result;
import com.lzh.core.controller.AbstractCoreController;
import com.lzh.user.entity.ApUserRealname;
import com.lzh.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* <p>
* APP实名认证信息表 控制器</p>
* @author lzh
* @since 2021-06-24
*/
@RestController
@RequestMapping("/apUserRealname")
public class ApUserRealnameController extends AbstractCoreController<ApUserRealname> {

    private ApUserRealnameService apUserRealnameService;

    //注入
    @Autowired
    public ApUserRealnameController(ApUserRealnameService apUserRealnameService) {
        super(apUserRealnameService);
        this.apUserRealnameService = apUserRealnameService;
    }

    /**
     * 审核通过
     * @param id ap_user_realname表 id
     * @return
     */
    @PutMapping("/pass")
    public Result pass(@RequestParam(value = "id") Integer id) {
        boolean res = apUserRealnameService.pass(id);
        if (res){
        return Result.ok("审核已通过");
        } else {
            return Result.error("用户不存在");
        }
    }

    //审核驳回
    @PutMapping("/reject")
    public Result reject(@RequestParam(value = "id") Integer id,@RequestParam(value = "reason") String reason) {
        boolean res = apUserRealnameService.reject(id,reason);
        if (res){
            return Result.ok("审核已通过");
        } else {
            return Result.error("用户不存在");
        }
    }
}

